package com.multithreading.algorithm;

/**
 * @author zx
 * @version 1.0
 * @package_name: com.multithreading.algorithm
 * @date 2024/6/19 15:42
 */
public class Array_test002 {
    public static void main(String[] args) {
        int[] source = new int[]{5, 4, 6, 8, 9, 0, 1, 2, 7, 3};

        // 声明三个特征值
        int sum = 0;
        int min = source[0];
        int max = source[0];
        for (int i = 0; i < source.length; i++) {
            // 求和
            sum += source[i];
            // 求最小值
            if (source[i] < min) {
                min = source[i];
            }
            // 求最大值
            if (source[i] > max) {
                max = source[i];
            }
        }
        // 求平均值
        double avg = (double) (sum - max - min) / (source.length - 2);
        System.out.println("平均值：" + avg);

    }
}
